function playerDeath()
    player.health.value = 0
    player.onDeath.hasRun = true
    player.onDeath.needsRun = false
    level.text[#level.text + 1] = {text = "Game Over!", x = 1920/2 - hudFontGO:getWidth("Game Over!")/2, y = 1080/2 - 200 - hudFontGO:getHeight("Game Over!")/2, color = color.red, font = hudFontGO}
    level.text[#level.text + 1] = {text = "[Esc] Exit", x = 1920/2 - hudFontLarge:getWidth("[Esc] Exit")/2, y = 800 - hudFontLarge:getHeight("[Esc] Exit")/2, color = color.red, font = hudFontLarge}
    
    if gameScore > highScore then
      level.text[#level.text + 1] = {text = "High Score!", x = 1920/2 - hudFontLarge:getWidth("High Score!")/2, y = 550, color = color.white, font = hudFontLarge}
    end
    
    --Use a second distance position away from the player to lower the volume a bit
    local exp = EntitySystem.entity.explosion2(player.position.x,player.position.y, player.position.x+350, player.position.y+350, 1)
    EntitySystem.detach(player, "animation", "physics")
    
    for e in pairs(EntitySystem.query("playerTracker")) do
      EntitySystem.detach(e, "trackPlayer")
    end
end

function enemyDeath1(e)
  e.onDeath.hasRun = true
  e.onDeath.needsRun = false
  if e.type then
    local exp = EntitySystem.entity.explosion1(e.position.x,e.position.y, player.position.x, player.position.y, e.type.num)
  else
    local exp = EntitySystem.entity.explosion1(e.position.x,e.position.y, player.position.x, player.position.y, 1)
  end
  EntitySystem.delete(e)
end

function deleteEnt(e)
  EntitySystem.delete(e)
end